FROM    docker.io/debian:latest

MAINTAINER  root   <root.db.root@gmail.com>

RUN     apt-get  update  -y 
RUN     apt-get  install -y openjdk-7-jre-headless wget 

ADD supervisord.conf /etc/supervisor/supervisord.conf

WORKDIR /opt

RUN wget  http://apache.mirrors.pair.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz 

RUN    tar zxf zookeeper-3.4.6.tar.gz   
RUN    mv /opt/zookeeper-3.4.6 /opt/zoo  
RUN    mv /opt/zoo/bin/zkEnv.sh  /opt/zoo/bin/zkEnv.sh.bak 
RUN    cp /opt/zoo/conf/zoo_sample.cfg /opt/zoo/conf/zoo.cfg  
RUN    mkdir  /opt/zoo/data 
RUN    mkdir  /opt/zoo/datalog
RUN    mkdir  /opt/zoo/logs    
RUN    echo "1" >/opt/zoo/data/myid  
RUN    mkdir -p /tmp/zookeeper

ADD java.env    /opt/zoo/conf/java.env
ADD zkEnv.sh    /opt/zoo/bin/zkEnv.sh 

WORKDIR  /opt/zoo

ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64

EXPOSE 2181 2888 3888 22 

CMD ["/usr/bin/supervisord"]
